/*
 * Copyright 2011-2011 Tiago da Fonseca Frazao  All rights reserved.
 */

package mz.co.research.shared.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @author Tiago da Fonseca Frazao
 */
@Entity
@Table(name = "ANSWER_DOMAIN_ITEM")
public class AnswerDomainItem extends UpdatableEntity {

	@NotNull
	@Column(name = "CODE", length = 25, nullable = false)
	private String code;

	@NotNull
	@Size(max = 255)
	@Column(name = "DESCRIPTION", length = 255, nullable = true)
	private String description;

	@NotNull
	@Column(name = "POSITION", nullable = false)
	private Long order;

	@ManyToOne
	@JoinColumn(name = "FK_ANSWER_DOMAIN_ID", nullable = false)
	private AnswerDomain answerDomain;

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code
	 *            the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the order
	 */
	public Long getOrder() {
		return order;
	}

	/**
	 * @param order
	 *            the order to set
	 */
	public void setOrder(Long order) {
		this.order = order;
	}

	/**
	 * @return the answerDomain
	 */
	public AnswerDomain getAnswerDomain() {
		return answerDomain;
	}

	/**
	 * @param answerDomain
	 *            the answerDomain to set
	 */
	public void setAnswerDomain(AnswerDomain answerDomain) {
		this.answerDomain = answerDomain;
	}

	@Override
	public String toString() {
		StringBuilder buffer = new StringBuilder("\nAnswerDomainItem");

		buffer.append(super.toString());

		buffer.append("\ncode         :" + this.code);
		buffer.append("\ndescription  :" + this.description);
		buffer.append("\norder        :" + this.order);

		return buffer.toString();
	}
}
